<template>
  <div id="app">
    <div class="appContainer">
      <!-- 头部区域 -->
      <mt-header fixed title="黑马程序员·Vue项目">
        <!-- 返回功能 -->
        <a  href="javascript:window.history.back();" slot="left" v-show="isShowBack">
          <mt-button icon="back">返回</mt-button>
        </a>
      </mt-header>
      <!-- 内容区域 -->
      <main>
        <!-- 路由显示区域 -->
        <router-view></router-view>
      </main>
      <!-- 底部区域 -->
      <footer>
        <nav class="mui-bar mui-bar-tab">
          <router-link class="mui-tab-itemBill" to="/home">
            <span class="mui-icon mui-icon-home"></span>
            <span class="mui-tab-label">首页</span>
          </router-link>
          <router-link class="mui-tab-itemBill" to="/member">
            <span class="mui-icon mui-icon-contact"></span>
            <span class="mui-tab-label">会员</span>
          </router-link>
          <router-link class="mui-tab-itemBill" to="/shopCar">
            <span class="mui-icon mui-icon-extra mui-icon-extra-cart"><span class="mui-badge" v-show="$store.getters.getShopCarCount > 0">{{ $store.getters.getShopCarCount }}</span></span>
            <span class="mui-tab-label">购物车</span>
          </router-link>
          <router-link class="mui-tab-itemBill" to="/search">
            <span class="mui-icon mui-icon-search"></span>
            <span class="mui-tab-label">搜索</span>
          </router-link>
        </nav>
      </footer>
    </div>
  </div>
</template>

<script>
  export default {
      data() {
          return {

          }
      },
      computed: {
          // 判断 现在的 路由是否 和 /home 相同 相同显示 back
          isShowBack() {
            return this.$route.path !== '/home'
          }
      }
  }
</script>


<style lang="less" scoped>
  .appContainer {
    padding: 40px 0 50px 0;
    header {
      z-index: 99;
    }
    // main
    main {
      width: 100%;
      height: 100%;
    }
    // 底部 Tabbar
    footer {
      .mui-bar-tab .mui-tab-itemBill.mui-active {
        color: #007aff;
      }
      .mui-bar-tab .mui-tab-itemBill {
        display: table-cell;
        overflow: hidden;
        width: 1%;
        height: 50px;
        text-align: center;
        vertical-align: middle;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: #929292;
      }
      .mui-bar-tab .mui-tab-itemBill .mui-icon {
        top: 3px;
        width: 24px;
        height: 24px;
        padding-top: 0;
        padding-bottom: 0;
      }
      .mui-bar-tab .mui-tab-itemBill .mui-icon~.mui-tab-label {
        font-size: 11px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
</style>
